var tableHtml = '<table  class="am-table am-table-bordered am-table-radius am-table-striped" id="videoTreeTable">' +
    '<tr data-tt-id="0"><td class="clickon1"><span class ="directory">可见光影像</span></td></tr>' +
    '<tr data-tt-id="1" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">天绘系列卫星</span></td></tr>' +
    '<tr data-tt-id="1-1" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">BWD</span></td></tr>' +
    '<tr data-tt-id="1-1-1" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_3_883_123.rpc</span></td></tr>' +
    '<tr data-tt-id="1-1-2" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_4_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="1-1-3" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_5_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="1-1-4" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_6_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="1-1-5" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_7_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="1-1-6" data-tt-parent-id="1-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_8_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="1-2" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">CMD</span></td></tr>' +
    '<tr data-tt-id="1-2-1" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">1H01-01_R201202210000003_1A_SXZ_3_883_123.rpc</span></td></tr>' +
    '<tr data-tt-id="1-2-2" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">2H01-01_R201202210000003_1A_SXZ_3_883_124.tif</span></td></tr>' +
    '<tr data-tt-id="1-2-3" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">3H01-01_R201202210000003_1A_SXZ_3_883_125.tif</span></td></tr>' +
    '<tr data-tt-id="1-2-4" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">4H01-01_R201202210000003_1A_SXZ_3_883_126.tif</span></td></tr>' +
    '<tr data-tt-id="1-2-5" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">5H01-01_R201202210000003_1A_SXZ_3_883_127.tif</span></td></tr>' +
    '<tr data-tt-id="1-2-6" data-tt-parent-id="1-2"><td class="clickon2"><span class="file">6H01-01_R201202210000003_1A_SXZ_3_883_128.tif</span></td></tr>' +
    '<tr data-tt-id="2" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">高分系列卫星</span></td></tr>' +
    '<tr data-tt-id="3" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">资源系列卫星</span></td></tr>'+
    '<tr data-tt-id="4"><td class="clickon1"><span class ="directory">非可见光影像</span></td></tr>' +
    '<tr data-tt-id="5" data-tt-parent-id="4"><td class="clickon1"><span class ="directory">天绘系列卫星</span></td></tr>' +
    '<tr data-tt-id="5-1" data-tt-parent-id="4"><td class="clickon1"><span class ="directory">BWD</span></td></tr>' +
    '<tr data-tt-id="5-1-1" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_3_883_123.rpc</span></td></tr>' +
    '<tr data-tt-id="5-1-2" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_4_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="5-1-3" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_5_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="5-1-4" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_6_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="5-1-5" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_7_883_123.tif</span></td></tr>' +
    '<tr data-tt-id="5-1-6" data-tt-parent-id="5-1"><td class="clickon2"><span class="file">TH01-01_R201202210000003_1A_SXZ_8_883_123.tif</span></td></tr>' ;
var tableHtml2 = '<table  class="am-table am-table-bordered am-table-radius am-table-striped" id="videoTreeTable">' +
    '<tr data-tt-id="0"><td class="clickon1"><span class ="directory">可见光影像</span></td></tr>' +
    '<tr data-tt-id="1" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">天绘系列卫星</span></td></tr>' +
    '<tr data-tt-id="1-1" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">BWD</span></td></tr>' +
    '<tr data-tt-id="1-2" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">CMD</span></td></tr>' +
    '<tr data-tt-id="1-3" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">DMD</span></td></tr>' +
    '<tr data-tt-id="1-4" data-tt-parent-id="1"><td class="clickon1"><span class ="directory">EMD</span></td></tr>' +
    '<tr data-tt-id="2" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">高分系列卫星</span></td></tr>' +
    '<tr data-tt-id="2-1" data-tt-parent-id="2"><td class="clickon1"><span class ="directory">AMD</span></td></tr>' +
    '<tr data-tt-id="2-2" data-tt-parent-id="2"><td class="clickon1"><span class ="directory">NMD</span></td></tr>' +
    '<tr data-tt-id="3" data-tt-parent-id="0"><td class="clickon1"><span class ="directory">资源系列卫星</span></td></tr>'+
    '<tr data-tt-id="4"><td class="clickon1"><span class ="directory">非可见光影像</span></td></tr>' +
    '<tr data-tt-id="5" data-tt-parent-id="4"><td class="clickon1"><span class ="directory">地绘系列卫星</span></td></tr>' +
    '<tr data-tt-id="5-1" data-tt-parent-id="5"><td class="clickon1"><span class ="directory">BND</span></td></tr>' +
    '<tr data-tt-id="5-4" data-tt-parent-id="5"><td class="clickon1"><span class ="directory">END</span></td></tr>';

$("#init_veideo").on("click","#initveido_btn",function () {
    $("#treetableView").html(tableHtml);
    $("#videoTreeTable").treetable({ expandable: true });
    $("#videoTreeTable").treetable("expandAll");
    $("#videoTreeTable").on("click",".clickon2",function () {
        $("#videoTreeTable .background_color").each(function (idx, elem) {
            var $elem = $(elem);
            $elem.removeClass("background_color");
        });
        $(this).addClass("background_color");
        var fileId = $(this).parent().attr("data-tt-id");
        var file = fileId.split("-");
        var parentid = $("tr[data-tt-id="+file[0]+"]").attr("data-tt-parent-id");
        if(file.length==1){
            $("#initviedio").val($(this).children(".file").html());
        }else {
            var strFile = file[0];
            var strDicHtm =$("tr[data-tt-id="+parentid+"]").children().children(".directory").html()+"/"+$("tr[data-tt-id="+file[0]+"]").children().children(".directory").html();
            for(var i=1;i<file.length-1;i++){
                strFile = strFile+"-"+file[i];
                strDicHtm = strDicHtm+"/"+$("tr[data-tt-id="+strFile+"]").children().children(".directory").html();
            }
            var allHtml = strDicHtm+"/"+$(this).children(".file").html();
            $("#initviedio").val(allHtml);
        }
    });
});
$("#target_path").on("click","#pathBrowse",function () {
    $("#treetableView").html(tableHtml2);
    $("#videoTreeTable").treetable({ expandable: true });
    $("#videoTreeTable").treetable("expandAll");
    $("#videoTreeTable").on("click",".clickon1",function () {
        $("#videoTreeTable .background_color").each(function (idx, elem) {
            var $elem = $(elem);
            $elem.removeClass("background_color");
        });
        $(this).addClass("background_color");
        var fileId = $(this).parent().attr("data-tt-id");
        var file = fileId.split("-");
        var parent = $("tr[data-tt-parent-id="+file[0]+"]")
        var parentid = $("tr[data-tt-id="+file[0]+"]").attr("data-tt-parent-id");
        if(parentid==null){
            $("#finalViedio").val($(this).children(".directory").html());
        }else{
            if(file.length==1){
                var strDicHtm =$("tr[data-tt-id="+parentid+"]").children().children(".directory").html()+"/"+$(this).children(".directory").html();
                $("#finalViedio").val(strDicHtm);
            }else{
                var strFile = file[0];
                var strDicHtm =$("tr[data-tt-id="+parentid+"]").children().children(".directory").html()+"/"+$("tr[data-tt-id="+file[0]+"]").children().children(".directory").html();
                for(var i=1;i<file.length-1;i++){
                    strFile = strFile+"-"+file[i];
                    strDicHtm = strDicHtm+"/"+$("tr[data-tt-id="+strFile+"]").children().children(".directory").html();
                }
                var allHtml = strDicHtm+"/"+$(this).children(".directory").html();
                $("#finalViedio").val(allHtml);
            }
        }
    });
});